import java.util.Scanner;

public class Main1159 {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int[] arr=new int[n];
        int x= sc.nextInt();
        for (int i=0;i<n;i++){
            arr[i]= sc.nextInt();
        }
        int p=0;
        for (int i=0;i<n;i++){
            if (arr[i]==x){
              p=i;//x数所在的位置
              if (p!=(n-1)){
                  int temp =arr[p];
                  arr[p]=arr[n-1];
                  arr[n-1]=temp;
              }
              for (i=0;i<n;i++){
                  System.out.print(arr[i]+" ");
              }
            }
        }
    }
}
